home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
cnews004.zip
/
MSCBUGS.ZIP
/
MSC5BUG4.C
< prev
Wrap
C/C++ Source or Header
|
1987-12-15
|
712b
|
26 lines
/* TEST APPENDING TEXT TO A FILE TERMINATED WITH CTRL-Z */
/* WORKS CORRECTLY UNDER VERSION 4 BUT FAILS UNDER VERSION 5 */
#include <assert.h>
#include <io.h>
#include <memory.h>
#include <process.h>
#include <stdio.h>
main()
{
static char old[] = { 'x', 'y' }, new[sizeof(old)];
FILE *fp; static char nam[] = "XXXXXX";
mktemp( nam );
fp = fopen( nam, "wb" );
fwrite( old, 1, 1, fp );
fputc( '\x1A', fp ); /* old-style end-of-file */
fclose( fp );
fp = fopen( nam, "at" );
fwrite( old+1, sizeof(old)-1, 1, fp );
fclose( fp );
fp = fopen( nam, "rt" );
fread( new, sizeof(new), 1, fp );
fclose( fp );
assert( ! memcmp( old, new, sizeof( old ) ) );
return remove( nam );
}